subroutine WsigmaLayerWithoutObj(params,ig,jg,ggu,ggl,di,f,l1,v1,v2,v3,&
    v4,v5,ggl2,ggu2,di2,vertex3D,nVer3D,nInCat3D,igT3D,jgT3D,ggT3D,&
    igEarth,jgEarth,log_txt,zLayers,nLayers,areaObjects,areaType,&
    nAreaObjects,xObjects,yObjects,zObjects,numbersObjects,nXObjects,&
    nYObjects,nZObjects,nObjects,numArea,vnXYZ,va,wnXYZ,wa)
    common /dim3D/nodesCount3D,elemsCount3D,nodesBoundCount3D,&
    edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,nodesTermCount3D,&
    m3D,mTerm3d,nodesNotTermCount3D
    common /commonInfo/ eps2d,eps3d,eps3dNS,radiusRED,maxiter,typeTask,nt,nMaterials,calcWK,calcVP
    common /dimEarth/nodesNotTermEarth,mEarth
    integer log_txt,areaObjects,areaType
    integer edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,elemsCount3D,elementsEarth
    real*8 eps2d,eps3d,eps3dNS,radiusRED,ggT3D,wa,zLayers,va,vnXYZ,xObjects,yObjects,zObjects
    real*8 vertex3D,params,ggu,ggl,di,f,v1,v2,v3,v4,v5,residual,ggl2,ggu2,di2,wnXYZ
    dimension params(10,nMaterials),ig(nodesNotTermCount3D+1),jg(m3d),ggu(m3d),&
    ggl(m3d),di(nodesNotTermCount3D),f(nodesNotTermCount3D),l1(nodesBoundCount3D),&
    v1(nodesNotTermCount3D),v2(nodesNotTermCount3D),v3(nodesNotTermCount3D),&
    v4(nodesNotTermCount3D),v5(nodesNotTermCount3D),ggl2(m3d),ggu2(m3d),&
    di2(nodesNotTermCount3D),vertex3D(3,nodesCount3D),nVer3D(14,elemsCount3D),&
    nInCat3D(elemsCount3D),wnXYZ(nodesCount3D),igT3D(nodesTermCount3D+1),jgT3D(mTerm3d),&
    ggT3D(mTerm3d),wa(nodesCount3D),igEarth(nodesNotTermEarth+1),jgEarth(mEarth),&
    zLayers(nLayers),va(nodesCount3D),vnXYZ(nodesCount3D),areaObjects(nAreaObjects),&
    areaType(2,nLayers+nObjects),xObjects(nXObjects),yObjects(nYObjects),&
    zObjects(nZObjects),numbersObjects(6,nObjects)

    call clearVectorDouble(wa,nodesCount3D)
    !Assembling global matrix
    call globalWsigmaLayerWithoutObj(ggl,ggu,di,f,vertex3D,nVer3D,&
    nInCat3D,ggT3D,igT3D,jgT3D,ig,jg,vnXYZ,va,wnXYZ,numArea,zLayers,nLayers,&
    areaObjects,areaType,nAreaObjects,xObjects,yObjects,zObjects,numbersObjects,&
    nXObjects,nYObjects,nZObjects,nObjects,params)

    !Taking into account boundary condition
    call firstCondition(di,f,l1,nodesNotTermCount3D,nodesBoundCount3D,1)
    k=1
    do i=1,nodesNotTermEarth
        j=ig(i)
        do while(j<=ig(i+1)-1.and.jg(j)<=nodesNotTermEarth)
            ggl2(k)=ggl(j)
            ggu2(k)=ggu(j)
            j=j+1
            k=k+1
        enddo 
    enddo

    !Solving SLAE
    call LOS2(wa,f,igEarth,jgEarth,ggl2,ggu2,di,nodesNotTermEarth,mEarth,&
    maxiter,eps3d,v1,v2,v3,v4,v5,0,iter,residual)
    call calculateValueForNotTermNodes(wa,igT3D,jgT3D,ggT3D,nodesCount3D,&
    mTerm3d,nodesTermCount3D,nodesNotTermCount3D)

2   format(A,i5,' residual =',E)
    write(*,2) 'VP: end W_a:       iter =',iter,residual
    write(log_txt,2) 'VP: end W_a:       iter =',iter,residual
end
!*************************************************************************
subroutine globalWsigmaLayerWithoutObj(ggl,ggu,di,f,vertex3D,nVer3D,&
    nInCat3D,ggT3D,igT3D,jgT3D,ig,jg,vnXYZ,va,wnXYZ,numArea,zLayers,nLayers,&
    areaObjects,areaType,nAreaObjects,xObjects,yObjects,zObjects,numbersObjects,&
    nXObjects,nYObjects,nZObjects,nObjects,params)
    common /dim3D/nodesCount3D,elemsCount3D,nodesBoundCount3D,edgesTermCount3D,&
    edgesNotTermCount3D,edgesCount3D,nodesTermCount3D,m3D,mTerm3d,nodesNotTermCount3D
    common /commonInfo/ eps2d,eps3d,eps3dNS,radiusRED,maxiter,typeTask,nt,nMaterials,calcWK,calcVP
    integer edgesTermCount3D,edgesNotTermCount3D,edgesCount3D,elemsCount3D,&
    elementsEarth,typeTask,calcWK,calcVP,areaObjects,areaType
    real*8 vertex3D,params,ggu,ggl,di,f,ggl2,ggu2,di2,wnXYZ,va,w,zLayers,vnXYZ,&
    xObjects,yObjects,zObjects,ggT3D,va_lok,vn_lok,b,x1,x2,y1,y2,z1,z2,g,&
    sigma0,eps2d,eps3d,eps3dNS,radiusRED
    dimension params(10,nMaterials),ig(nodesNotTermCount3D+1),jg(m3d),ggu(m3d),ggl(m3d),&
    di(nodesNotTermCount3D),f(nodesNotTermCount3D),vertex3D(3,nodesCount3D),&
    nVer3D(14,elemsCount3D),nInCat3D(elemsCount3D),wnXYZ(nodesCount3D),&
    va(nodesCount3D),igT3D(nodesTermCount3D+1),jgT3D(mTerm3d),ggT3D(mTerm3d),&
    va_lok(8),vn_lok(8),b(8,8),g(8),w(8),zLayers(nLayers),vnXYZ(nodesCount3D),&
    areaObjects(nAreaObjects),areaType(2,nLayers+nObjects),xObjects(nXObjects),&
    yObjects(nYObjects),zObjects(nZObjects),numbersObjects(6,nObjects),sigma0(3,3)

    call clear(ggl,ggu,di,f,nodesNotTermCount3D,m3D)
    do i=1,elemsCount3D
        x1=vertex3D(1,nVer3D(1,i))
        x2=vertex3D(1,nVer3D(2,i))
        y1=vertex3D(2,nVer3D(1,i))
        y2=vertex3D(2,nVer3D(3,i))
        z1=vertex3D(3,nVer3D(1,i))
        z2=vertex3D(3,nVer3D(5,i))
        do j=1,8
            va_lok(j)=va(nVer3D(j,i))
            vn_lok(j)=vnXYZ(nVer3D(j,i))
            w(j)=wnXYZ(nVer3D(j,i))
        enddo
        
        sigma0(1,1)=params(10,nInCat3D(i))
        sigma0(2,2)=params(10,nInCat3D(i))
        sigma0(3,3)=params(10,nInCat3D(i))

        !Assembling local matrix
        call LocalMatrixWsigmaLayerWithoutObj(b,g,x1,x2,y1,y2,z1,z2,&
        vn_lok,va_lok,w,params(1,nInCat3D(i)),sigma0,numArea,zLayers,nLayers,areaObjects,&
        areaType,nAreaObjects,xObjects,yObjects,zObjects,numbersObjects,&
        nXObjects,nYObjects,nZObjects,nObjects)

        !Adding local matrix to global
        call AddLocal(di,ig,jg,ggl,ggu,f,b,g,nVer3D(1,i),nodesNotTermCount3D,&
        m3D,8,igT3D,jgT3D,ggT3D,nodesTermCount3D,mTerm3d,1)
    enddo
end
!*************************************************************************
!Assembling local matrix
subroutine LocalMatrixWsigmaLayerWithoutObj(b,g,x1,x2,y1,y2,z1,z2,vn,va,&
    w,sigma,sigma0,numArea,zLayers,nLayers,areaObjects,areaType,nAreaObjects,&
    xObjects,yObjects,zObjects,numbersObjects,nXObjects,nYObjects,&
    nZObjects,nObjects)
    dimension b1(2,2),c1(2,2),b(8,8),g(8),gn(8),ga(8),vn(8),va(8),w(8),gAdd(8),&
    zLayers(nLayers+1),areaObjects(nAreaObjects),areaType(2,nLayers+nObjects),&
    xObjects(nXObjects),yObjects(nYObjects),zObjects(nZObjects),d1(2,2),d2(2,2),&
    numbersObjects(6,nObjects),sigma0(3,3),pr(8,8),sigma(3,3),b0(8,8)
    real*8 b1,c1,b,hx,hy,hz,g,gn,ga,x1,x2,y1,y2,z1,z2,vn,va,sigma,sigma0,w,&
    gAdd,zLayers,xObjects,yObjects,zObjects,d1,d2,pr,b0
    integer delta,d,areaObjects,areaType

    b1(1,1)=1.d0
    b1(1,2)=-1.d0
    b1(2,1)=-1.d0
    b1(2,2)=1.d0

    c1(1,1)=2.d0/6.d0
    c1(1,2)=1.d0/6.d0
    c1(2,1)=1.d0/6.d0
    c1(2,2)=2.d0/6.d0
    
    d1(1,1)=-1.d0/2.d0
    d1(1,2)=-1.d0/2.d0
    d1(2,1)=1.d0/2.d0
    d1(2,2)=1.d0/2.d0
    
    d2(1,1)=-1.d0/2.d0
    d2(1,2)=1.d0/2.d0
    d2(2,1)=-1.d0/2.d0
    d2(2,2)=1.d0/2.d0

    hx=x2-x1
    hy=y2-y1
    hz=z2-z1
    do i=1,8
        do j=1,8
            mi=mu_3d(i)
            mj=mu_3d(j)
            ni=nu_3d(i)
            nj=nu_3d(j)
            ki=ku_3d(i)
            kj=ku_3d(j)
            b(i,j)=&
            sigma(1,1)*(1.d0/hx*b1(mi,mj)*hy*c1(ni,nj)*hz*c1(ki,kj))+&
            sigma(1,2)*(d2(mi,mj)*d1(ni,nj)*hz*c1(ki,kj))+&
            sigma(1,3)*(d2(mi,mj)*hy*c1(ni,nj)*d1(ki,kj))+&

            sigma(2,1)*(d1(mi,mj)*d2(ni,nj)*hz*c1(ki,kj))+&
            sigma(2,2)*(hx*c1(mi,mj)*1.d0/hy*b1(ni,nj)*hz*c1(ki,kj))+&
            sigma(2,3)*(hx*c1(mi,mj)*d2(ni,nj)*d1(ki,kj))+&

            sigma(3,1)*(d1(mi,mj)*hy*c1(ni,nj)*hz*d2(ki,kj))+&
            sigma(3,2)*(hx*c1(mi,mj)*d1(ni,nj)*d2(ki,kj))+&
            sigma(3,3)*(hx*c1(mi,mj)*hy*c1(ni,nj)*1.d0/hz*b1(ki,kj))


            b0(i,j)=&
            sigma0(1,1)*(1.d0/hx*b1(mi,mj)*hy*c1(ni,nj)*hz*c1(ki,kj))+&
            sigma0(2,2)*(hx*c1(mi,mj)*1.d0/hy*b1(ni,nj)*hz*c1(ki,kj))+& 
            sigma0(3,3)*(hx*c1(mi,mj)*hy*c1(ni,nj)*1.d0/hz*b1(ki,kj))


            pr(i,j)=&
            (sigma0(1,1)-sigma(1,1))*(1.d0/hx*b1(mi,mj)*hy*c1(ni,nj)*hz*c1(ki,kj))+&
            (sigma0(1,2)-sigma(1,2))*(d2(mi,mj)*d1(ni,nj)*hz*c1(ki,kj))+&
            (sigma0(1,3)-sigma(1,3))*(d2(mi,mj)*hy*c1(ni,nj)*d1(ki,kj))+&

            (sigma0(2,1)-sigma(2,1))*(d1(mi,mj)*d2(ni,nj)*hz*c1(ki,kj))+&
            (sigma0(2,2)-sigma(2,2))*(hx*c1(mi,mj)*1.d0/hy*b1(ni,nj)*hz*c1(ki,kj))+&
            (sigma0(2,3)-sigma(2,3))*(hx*c1(mi,mj)*d2(ni,nj)*d1(ki,kj))+&

            (sigma0(3,1)-sigma(3,1))*(d1(mi,mj)*hy*c1(ni,nj)*hz*d2(ki,kj))+&
            (sigma0(3,2)-sigma(3,2))*(hx*c1(mi,mj)*d1(ni,nj)*d2(ki,kj))+&
            (sigma0(3,3)-sigma(3,3))*(hx*c1(mi,mj)*hy*c1(ni,nj)*1.d0/hz*b1(ki,kj))
        enddo
    enddo

    call mult_sq(g,pr,w,8)
    call mult_sq(gn,b0,vn,8)
    call mult_sq(ga,b,va,8)

    nList=areaType(2,numArea)-areaType(2,numArea-1)
    ld=lidDelta(areaObjects(areaType(2,numArea-1)+1),&
    nList,x1,x2,y1,y2,z1,z2,zLayers,nLayers,numArea,& 
    xObjects,yObjects,zObjects,numbersObjects,nXObjects,&
    nYObjects,nZObjects,nObjects)
    d = delta(numArea,z1,z2,zLayers,nLayers)

    do i=1,8
        g(i)=g(i)-gn(i)*ld+ga(i)*d
    enddo
end
!*************************************************************************
!*************************************************************************
!*************************************************************************